﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using AutoMapper;
using PhoneBook.Models;
using PhoneBook.Dtos;
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace PhoneBook.Controllers
{
    public class AutoMapperController : Controller
    {
        private IMapper _mapper;
        public AutoMapperController(IMapper mapper)
        {
            _mapper = mapper;
        }
        // GET: /<controller>/
        public PetDto Index()
        {
            Pet p = new Pet
            {
                Name = "adm",
                ID = 1

            };
            PetDto result=_mapper.Map<PetDto>(p);
            return result;
        }

        public PetDto Index1()
        {
            Pet p = new Pet
            {
                Name = "adm",
                ID = 1

            };
            PetDto result = _mapper.Map<PetDto>(p,opt=> {
               
            });

            UserDto d = _mapper.Map<UserDto>(p);

            Pet p2= _mapper.Map<Pet>(d);


            PetDto toLoad = new PetDto
            {
                Name = "toloaddto",
                Id = 4
            };

            PetDto newDto=_mapper.Map(p,toLoad);

            return result;
        }
    }
}
